// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef PINS_TESTS_FORWARDING_ARRIBA_TEST_H_
#define PINS_TESTS_FORWARDING_ARRIBA_TEST_H_

#include <memory>
#include <string>

#include "dvaas/arriba_test_vector_validation.h"
#include "dvaas/test_vector.pb.h"
#include "thinkit/mirror_testbed_fixture.h"

namespace pins_test {

struct ArribaTestParams {
  // The testbed to be validated against the test vector.
  // Using a shared_ptr because parameterized tests require objects to be
  // copyable.
  std::shared_ptr<thinkit::MirrorTestbedInterface> mirror_testbed;
  // The test vector that is used for validation of the forwarding behavior of
  // the SUT in the given testbed.
  dvaas::ArribaTestVector arriba_test_vector;
  dvaas::ArribaTestVectorValidationParams validation_params;
  // If true, waits for all enabled ports to be up on SUT and control switch.
  bool wait_for_all_enabled_interfaces_to_be_up = true;
  const std::string description;
};

// An ArribaTest validates the given testbed against the given ArribaTestVector.
// It installs the entries in the test vector on the switch, injects the input
// packets, collects the output packets, and compares the results against the
// expected outputs in the test vector.
class ArribaTest : public testing::TestWithParam<ArribaTestParams> {
protected:
  void SetUp() override { GetParam().mirror_testbed->SetUp(); }
  void TearDown() override { GetParam().mirror_testbed->TearDown(); }
};

} // namespace pins_test

#endif // PINS_TESTS_FORWARDING_ARRIBA_TEST_H_
